package com.zj.core.activity

import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import android.widget.LinearLayout
import com.quitutils.SwipeBackLayout
import com.zj.core.adapter.VideoItemAdapter
import com.zj.core.base.TitleBarActivity
import com.zj.core.bean.VideoMesBean
import com.zj.core.interfaces.VideoItemIml
import com.zj.core.net.NetPresenter
import com.zj.core.net.NetValueCallBackIml
import com.zj.core.ui.HelpMessageUi

class HelpMesActivity: TitleBarActivity(){
    private var listBean:List<VideoMesBean.DatEntity.RowsEntity>?= ArrayList()
    private var adapterChilder: VideoItemAdapter?=null
    lateinit var helpUi: HelpMessageUi

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setQuitMode(SwipeBackLayout.EDGE_LEFT)
    }

    override fun onCreate(groupView: LinearLayout): View? {
        helpUi= HelpMessageUi(groupView)
        return helpUi.template_list_rv
    }

    override fun initView(){
        setTitleText("操作说明")

        adapterChilder = VideoItemAdapter(this, listBean)
        val mLayoutManager = LinearLayoutManager(this)
        mLayoutManager.orientation = LinearLayoutManager.VERTICAL
        with(helpUi){
            this.template_list_rv?.layoutManager =mLayoutManager
            this.template_list_rv?.adapter = adapterChilder
        }
        adapterChilder?.setItemListener(itemListener)

        NetPresenter().getVideoMessage(videoMesIml)
    }

    private var itemListener=object: VideoItemIml {
        override fun setItemClickListener(possion: Int,videoBean: VideoMesBean.DatEntity.RowsEntity) {
            with(Bundle()){
                this.putSerializable("video",videoBean)
                activityJump(this@HelpMesActivity, VideoPlayActivity().javaClass,this)
            }
        }
    }

    private var videoMesIml=object: NetValueCallBackIml {
        override fun onComplete() {}
        override fun onSubscribe(data: Any?) {}
        override fun onError() {}

        override fun onNext(values: Any?, bean: Any?){
            adapterChilder?.notifiDataChange(values as List<VideoMesBean.DatEntity.RowsEntity>)
        }
    }
}